// SPUtil.h: interface for the CSPUtil class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_SPUTIL_H__F4C18CF8_9EA4_494D_B1BF_0A8D3A741E36__INCLUDED_)
#define AFX_SPUTIL_H__F4C18CF8_9EA4_494D_B1BF_0A8D3A741E36__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "FutOptRcvr.h"
#include <string>
#include "Global.h"
using namespace std;

typedef
enum tagTimeRange
{
	itrH = 0,
	itrM = 1,
	itrS = 2,
	itrNA = 100
} 	TimeRange;


class CSPUtil  
{
public:
	CSPUtil();
	virtual ~CSPUtil();

	static long GetToday();
	static double Round(double a_Input);
	static double MultipleRound(double a_Input, double a_Decimal);
	static string KRToGom(string a_Code);
	static string KRToCP(string a_Code);
	static string MakeChartSerial(string a_Code, long a_DataType, long a_BaseType, long a_Period);
	static string MakeChartSerial(ChartParam& a_Param);
	static COleDateTime LongToDate(long a_Date, long a_Time);
	static COleDateTime StringToDate(string a_Date, string a_Time);
	static COleDateTime StringToDate(string a_Time);
	static int GetTime(string a_Time, TimeRange a_Type);
	static void MakeJamesZoneData(ChartDataList* a_DataList);
	static double FindJamesValue(ChartDataList* a_DataList, int a_Type);
	static bool IsInTime(long a_Time);
	// 1 : upper band, 2 : lower band, 0 : neutral.
	static int WhichBandIsNear(double a_Current, int a_Index);
	static BandType WhichBandIsNear(CChartMultiData* a_Data, int a_Index);
	static int LastBandArea(int a_Index, CChartMultiData* a_MultiData);
	static int FirstIndexInLastEvenBand(int a_Index, CChartMultiData* a_MultiData);
	static bool IsInLowerBand(int a_Index, double a_Current);
	static bool IsInUpperBand(int a_Index, double a_Current);
	static int  GetUpperEvenCount(int a_Index);
	static int  GetLowerEvenCount(int a_Index);
	static int  GetBandCrossCount(int a_Index, CChartMultiData* a_MultiData);
	static int  GetLastBandCrossIndex(int a_Index, CChartMultiData* a_MultiData);
	static long KRTimeToLong(string a_Time);
	static int  GetDayIndex(int a_Index, CChartMultiData* a_MultiData);
	static bool IncludedDayHigh(int a_Index, int a_Span, CChartMultiData* a_MultiData);
	static bool IncludedDayLow(int a_Index, int a_Span, CChartMultiData* a_MultiData);
	static int  UnderLowCountInUpperBand(int a_Index, int a_Span, CChartMultiData* a_MultiData);
	static int  OverHighCountInLowerBand(int a_Index, int a_Span, CChartMultiData* a_MultiData);
	static double GetDayHeight(int a_Index);
	static double GetDayHigh(int a_Index);
	static double GetDayLow(int a_Index);
	static void GetMinMaxAvg(double& a_Min, double& a_Max, double& a_Avg);
	static bool IsInFarRangeUnderTop(int a_Index, double a_Distance, CChartMultiData* a_MultiData);
	static bool IsInFarRangeOverBottom(int a_Index, double a_Distance, CChartMultiData* a_MultiData);
	static bool IsReachedBottomLimitHigh(int a_Index, CChartMultiData* a_MultiData);
	static bool IsReachedUpperLimitLow(int a_Index, CChartMultiData* a_MultiData);
};

#endif // !defined(AFX_SPUTIL_H__F4C18CF8_9EA4_494D_B1BF_0A8D3A741E36__INCLUDED_)
